const nums = [2, 7, 11, 15];
const target = 9;

const hashMap = new Map();
for (let i = 0; i < nums.length; i++) {
    let temp = target - nums[i];
    if (hashMap.has(temp)) {
        console.log(hashMap.get(temp), i);
        break;
    }
    hashMap.set(nums[i], i);
}

